import type { ComputedRef } from 'vue'

import type { ButtonOptions } from '@/types/propTypes'

export interface BasicDialogProps {
  dialogVisible: boolean
  confirmLoading: boolean
  cancelText?: string
  okText?: string
  cancelButtonProps?: Partial<ButtonOptions>
  showCancelBtn?: boolean
  okButtonProps?: Partial<ButtonOptions>
  showOkBtn?: boolean
  title?: string
  draggable?: boolean
  center?: boolean
  alignCenter?: boolean
  width?: number | string
  closeFunc?: () => Promise<boolean>
  fullscreen?: boolean
  top?: string
  modal?: boolean
  modalClass?: string
  appendToBody?: boolean
  appendTo?: HTMLElement | string
  lockScroll?: boolean
  /**
   * 是否可以通过点击 modal 关闭 Dialog
   */
  closeOnClickModal?: boolean
  closeOnPressEscape?: boolean
  footerClass?: string
  zIndex?: number
}

export interface ModalMethods {
  setModalProps: (props: Partial<BasicDialogProps>) => void
  emitVisible?: (visible: boolean, uid: number) => void
}
export interface ReturnMethods extends ModalMethods {
  openDialog: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
  closeModal: () => void
  getVisible?: ComputedRef<boolean>
}
export type RegisterFn = (modalMethods: ModalMethods, uuid: string) => void

export type UseModalReturnType = [RegisterFn, ReturnMethods]
export interface ReturnInnerMethods extends ModalMethods {
  closeModal: () => void
  changeOkLoading: (loading: boolean) => void
  getVisible?: ComputedRef<boolean>
}
export type UseDialogInnerReturnType = [RegisterFn, ReturnInnerMethods]
